﻿
Partial Class AdminNewTaxists
    Inherits Page

    Public Taxists As List(Of taxist)
    Public Total As Integer
    Public Cities As List(Of cities)

    Public IsOnline As String = "off"
    Public CityId As Guid = Guid.Empty

    Protected Overrides Sub OnLoad(e As EventArgs)
        MyBase.OnLoad(e)

        If Request.Form.HasKeys() Then
            isOnline = Request.Form("isonline")
            cityId = Guid.Parse(Request.Form("cityid").ToString())
        End If

        If Request.QueryString.Keys.Count > 0 Then
            Try
                isOnline = Request.QueryString("isonline")
                cityId = Guid.Parse(Request.QueryString("cityid").ToString())
            Catch ex As Exception

            End Try
        End If

        Using context As New TaxiEntities()

            total = context.taxist.Count(CType(Function(a) (isOnline <> "on" Or a.taxi_isonline = True) And (cityId = Guid.Empty Or a.city_id = cityId), Func(Of taxist, Boolean)))
            taxists = context.taxist.Include("transfers").Include("cities").Where(CType(Function(a) (isOnline <> "on" Or a.taxi_isonline = True) And (cityId = Guid.Empty Or a.city_id = cityId), Func(Of taxist, Boolean))).OrderByDescending(Function(a) a.taxi_created).ToList()
            cities = context.cities.ToList()

        End Using

    End Sub

End Class
